package com.lgx.mall.business.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import net.sf.json.JSONObject;

import com.lgx.common.entity.IdGenerator;
import com.lgx.common.web.util.DateUtils;
import com.lgx.common.web.util.DictUtils;

/**
 * 返利
 * @author pengdeyi
 *
 */
@Entity
@Table(name="TM_REBATE")
public class Rebate implements Serializable {
	
	public static final String FLLX_LEVEL_MERCHANT = "01";  //商家
	
	public static final String FLLX_LEVEL_ORGANIZATION_TGZ = "02";  //推广站
	
	public static final String FLLX_LEVEL_ORGANIZATION_TGSTATION = "03";  //推广中心
	
	public static final String FLLX_LEVEL_ORGANIZATION_TGCENTER = "04";   //运营中心
	
	public static final int FLZT_INIT = 1;						//返利状态初始化
	
	public static final int FLZT_OVER = 2;						//已经兑换
	
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.REBATE_ID_GENERATOR)
	@TableGenerator(
			name = IdGenerator.REBATE_ID_GENERATOR,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.REBATE_ID_GENERATOR,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	@Column(name="receive_id")
	private long receiveId;//返利收益方ID
	
	private String receiveName;//返利收益方name
	
	private String startName;//反利发生方名称
	
	private String startId;//反利发生方ID
	
	private double amount;//返利额度
	
	private String type;//返利类型
	
	private Date rebateTime;//返利时间
	
	private int status;//返利状态

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getReceiveId() {
		return receiveId;
	}

	public void setReceiveId(long receiveId) {
		this.receiveId = receiveId;
	}

	public String getReceiveName() {
		return receiveName;
	}

	public void setReceiveName(String receiveName) {
		this.receiveName = receiveName;
	}

	public String getStartName() {
		return startName;
	}

	public void setStartName(String startName) {
		this.startName = startName;
	}

	public String getStartId() {
		return startId;
	}

	public void setStartId(String startId) {
		this.startId = startId;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getRebateTime() {
		return rebateTime;
	}

	public void setRebateTime(Date rebateTime) {
		this.rebateTime = rebateTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	
	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", this.getId());
		obj.put("receiveId", this.getReceiveId());       //返利收益方id  
		obj.put("receiveName", this.getReceiveName());   //返利收益放那么
		obj.put("startId", this.getStartId());           //返利发起方id
		obj.put("startName", this.getStartName());       //返利发起方name
		obj.put("amount", this.getAmount());             //返利额度
		obj.put("type",  DictUtils.getDictNameByKindAndCode(DictUtils.FLLX_LEVEL,this.getType()+""));   				 //返利类型
		obj.put("rebateTime", DateUtils.dateToChar(this.getRebateTime(),DateUtils.DATE_FORMAT_D));     					 //返利时间
		obj.put("status", DictUtils.getDictNameByKindAndCode(DictUtils.FLZT_INIT, this.getStatus()+""));          		 //返利状态，是否完成
		
		return obj.toString();
	}
	
}
